﻿using UnityEngine;
using System.Collections;
using UnityEditor;

public class PrefabEditor : Editor
{
    [MenuItem("YdTools/GenCharactorPrefab")]
    public static  void GenCharactorPrefab() {
        GameObject obj= AssetDatabase.LoadAssetAtPath("Assets/Charactor/Male/Male.FBX", typeof(GameObject)) as GameObject;
        obj = Instantiate(obj);
        SkinnedMeshRenderer[] renders=obj.GetComponentsInChildren<SkinnedMeshRenderer>();
        foreach (SkinnedMeshRenderer render in renders) {
            Debug.Log(render.gameObject.name);
            CreatePrefab(render.gameObject, "Assets/Prefabs/Male/"+ render.gameObject.name+".prefab");
        }
        DestroyImmediate(obj);
    }
    private static void CreatePrefab(GameObject obj,string path) {
        Object temp = PrefabUtility.CreateEmptyPrefab(path);
        temp = PrefabUtility.ReplacePrefab(obj, temp);
    }
}
